package com.teacher.pojo.enums.items;

import java.math.BigDecimal;

public enum VolunteerStartType {
    /**
     * 10->一星
     * 20->二星
     * 30->三星
     * 40->四星
     * 50 -> 五星
     */
    A(10, new BigDecimal("0.1"), "一星志愿者"),
    B(20, new BigDecimal("0.2"), "二星志愿者"),
    C(30, new BigDecimal("0.3"), "三星志愿者"),
    D(40, new BigDecimal("0.4"), "四星志愿者"),
    E(50, new BigDecimal("0.5"), "五星志愿者");
    private Integer code;
    private BigDecimal grades;
    private String name;

    VolunteerStartType(Integer code, BigDecimal grades, String name) {
        this.grades = grades;
        this.code = code;
        this.name = name;
    }

    /**
     * 通过code拿到名称
     *
     * @param type
     * @return
     */
    public static String getNameByCode(Integer type) {
        for (VolunteerStartType eType : VolunteerStartType.values()) {
            if (eType.code.equals(type)) {
                return eType.name;
            }
        }
        return "0";
    }

    /**
     * 通过code拿到分数
     *
     * @param type
     * @return
     */
    public static BigDecimal getGradesByCode(Integer type) {
        for (VolunteerStartType eType : VolunteerStartType.values()) {
            if (eType.code.equals(type)) {
                return eType.grades;
            }
        }
        return new BigDecimal(0);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public BigDecimal getGrades() {
        return grades;
    }

    public void setGrades(BigDecimal grades) {
        this.grades = grades;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
